package com.kws.tool.controller;

import com.kws.common.core.domain.R;
import com.kws.system.api.domain.MerchantDto;
import com.kws.tool.dto.ResultDto;
import com.kws.tool.dto.UserDto;
import com.kws.tool.service.UserVerifyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@RequestMapping("/user")
@Api(value = "实名校验", tags = "实名校验")
public class UserVerifyController {

    @Autowired
    UserVerifyService userVerifyService;

    @PostMapping("/aliVerify")
    @ApiOperation("阿里云-实名校验-姓名-身份证")
    public R aliVerify(@RequestBody UserDto userDto) throws IOException {
        return R.ok(userVerifyService.aliVerify(userDto));
    }


    @PostMapping("/eVerify")
    @ApiOperation("e签宝-实名校验-姓名-身份证")
    public R<ResultDto> eVerify(@RequestBody UserDto userDto) throws IOException {
        return R.ok(userVerifyService.eVerify(userDto));
    }

    //{"code":0,"message":"成功","data":{"flowId":"3684353980878031027"}}
    //{"code":30504001,"message":"信息比对不通过,请检查信息的正确性","data":null}
    @PostMapping("/merchantVerify")
    @ApiOperation("e签宝-商家三要素认证-姓名-机构-机构号码")
    public R merchantVerify(@RequestBody MerchantDto merchantDto) throws IOException {
        return R.ok(userVerifyService.merchantVerify(merchantDto));
    }

    @GetMapping("/reverseRemit/{flowId}")
    @ApiOperation("e签宝-商家反向打款认证--flowId通过商家三要素认证得到")
    public R reverseRemit(@PathVariable String flowId) throws IOException {
        return R.ok(userVerifyService.reverseRemit(flowId));
    }

}